#include "stdafx.h"
#include "AnimatedSystem.h"

#include "EntityManager.h"
#include "AnimatedComponent.h"
#include "GameEngine.h"

namespace ZeEngine
{
    AnimatedSystem::AnimatedSystem()
    {
        AddRequiredComponent("AnimatedComponent");
    }

    AnimatedSystem::~AnimatedSystem()
    {
    }

    bool AnimatedSystem::Update(GameEngine& gameEngine)
    {
        EntityManager& entityManager = gameEngine.GetEntityManager();

        auto store = entityManager.GetAllEntities();

        for (auto pEntity : store)
        {
            if (pEntity && IsEntitySupported(pEntity))
            {
                auto pAnimatedComponent = pEntity->GetComponent<AnimatedComponent>();

                if (pAnimatedComponent)
                {
                    pAnimatedComponent->Update(gameEngine.GetDeltaMS());
                }
            }
        }
        return false;
    }
}
